package com.objectimprove;

import java.util.Scanner;

public class Triangle {
    private double a1;
    private double a2;
    private double a3;

    public double getA1() {
        return a1;
    }

    public void setA1(double a1) {
        this.a1 = a1;
    }

    public double getA2() {
        return a2;
    }

    public void setA2(double a2) {
        this.a2 = a2;
    }

    public double getA3() {
        return a3;
    }

    public void setA3(double a3) {
        this.a3 = a3;
    }

    public Triangle(double a1, double a2, double a3) {
            this.a1 = a1;
            this.a2 = a2;
            this.a3 = a3;
    }

    public Triangle() {
    }

    //检查是否是一个三角形
    public boolean isValidTriangle(double a, double b, double c) {
        //三遍不可能为负数并且要满足勾股定理：两边之和大于第三边
        if (a > 0 && b > 0 && c > 0 && a + b > c && a + c > b && b + c > a) {
            return true;
        }
        return false;

    }

    //计算面积
    public double getArea() {
        //计算半周长
        double s = getPerimeter() / 2;
        //面积
        return Math.sqrt(s * (s - a1) * (s - a2) * (s - a3));
    }

    //计算周长
    public double getPerimeter() {
        return a1 + a2 + a3;
    }


}
